/**
 * @file   PA_C.cpp
 * @author ZL <zuoling@Black>
 * @date   Fri Oct  7 01:05:33 2022
 * 
 * @brief  1.8.2 PA_C
 * 
 * 
 */

#include "EquationSolver.h"
/** 
 * 
 * 
 * 
 * @return Create a function class based on known conditions.
 */
class F : public Function
{
public:
    double operator ()(double _x)
	{
	    double x = _x;
	    double y;
	    y = tan(x)-x;
	    return y;
	};
    double diff(double _x)
	{
	    double x = _x;
	    double y;
	    y = 1/pow(cos(x),2)-1;
	    return y;
	};
};

int main(int argc, char* argv[])
{
    F f;
    Newton n1(4.5, eps, 20, f);
    Newton n2(7.7, eps, 20, f);
    
    double y1 = n1.solve();
    double y2 = n2.solve();
    std::cout << "function'root near 4.5 is r1 = " << y1 <<", f(r1) = "<< (f)(y1)<<std::endl;
    std::cout << "function'root near 7.7 is r2 = " << y2 <<", f(r2) = "<< (f)(y2)<<std::endl; 
    return 0;
};
